//
//  SexTableViewCell.m
//  XiangMu
//
//  Created by 康世标 on 15/8/13.
//  Copyright (c) 2015年 康世标. All rights reserved.
//

#import "SexTableViewCell.h"

@implementation SexTableViewCell

- (void)awakeFromNib {
    // Initialization code
}
- (void)getCommen:(NSDictionary *)dic {
    
//    
//    if ([[dic1 valueForKey:@"state"] intValue]==0)
//    {
//        state = @"未付款";
//    }
//    else if ([[dic1 valueForKey:@"state"] intValue]==1){
//        state = @"进行中";
//    }
//    else if ([[dic1 valueForKey:@"state"] intValue]==2){
//        state = @"未评价";
//    }
//    else{
//        state = @"已完成";
//    }

    
    if ([[dic  valueForKey:@"state"] intValue]==0) {
        
        self.imagView1.image = [UIImage imageNamed:@"yuantwo"];
    }
    else if ([[dic  valueForKey:@"state"] intValue]==1){
        
        self.imagView1.image = [UIImage imageNamed:@"yuanthree"];
    }
    else if ([[dic  valueForKey:@"state"] intValue]==2){
        
        self.imagView1.image = [UIImage imageNamed:@"yuanone"];
    }
    else{
        
        self.imagView1.image =[UIImage imageNamed:@"yuanone"];
    }
    
    self.dingDanHao.text = [NSString stringWithFormat:@"%@",[dic valueForKey:@"id"]];
    self.daoDaShiJian.text  =[NSString stringWithFormat:@"陪护师将于%@到达",[self upDated:[dic valueForKey:@"created"]==[NSNull null]?0:[[dic valueForKey:@"created"] longValue]]];
    self.danJia.text  = [NSString stringWithFormat:@"%@元/%@",[dic valueForKey:@"price"]==[NSNull null]?@"":[dic valueForKey:@"price"],[dic valueForKey:@"timeType"]==[NSNull null]?@"":[dic valueForKey:@"timeType"]];
    
    int youHuiJia = [dic valueForKey:@"cheapPrice"]==[NSNull null]?0:[[dic valueForKey:@"cheapPrice"] intValue];
    
    int danJia = [dic valueForKey:@"price"]==[NSNull null]?0:[[dic valueForKey:@"price"] intValue];
    
    self.cheapPrice.text = [NSString stringWithFormat:@"%d元",youHuiJia];
    
    self.zongJia.text  =[NSString stringWithFormat:@"%d元",danJia-youHuiJia];
    

    if ([dic valueForKey:@"endTime"]==[NSNull null]) {
        
        self.daoQiShiJian.hidden = YES;
        self.daoQiTitle.hidden = YES;
    }
    else{
        self.daoQiShiJian.text  =[self upDated:[dic valueForKey:@"endTime"]==[NSNull null]?0:[[dic valueForKey:@"endTime"] longValue]];
    }



    
    self.xiaDanShiJian.text  =[NSString stringWithFormat:@"%@下单",[self upDated:[dic valueForKey:@"startTime"]==[NSNull null]?0:[[dic valueForKey:@"startTime"] longValue]]];



    
}
-(NSString *)upDated:(long )str{
    
    
    if (str==0) {
        
        return @"";
    }
  
    
    NSDate * date = [NSDate dateWithTimeIntervalSince1970:str/1000];
    
    NSDateFormatter * dataFormatter = [[NSDateFormatter alloc]init];
    
    [dataFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    
    NSString * string= [dataFormatter stringFromDate:date];
    
    return string;
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
